﻿#region Using directives

using System;
using System.Data;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using InvoiceChecking.Entities;
using InvoiceChecking.Data;

#endregion

namespace InvoiceChecking.Data.Bases
{	
	///<summary>
	/// This class is the base class for any <see cref="SunAccountCodeProviderBase"/> implementation.
	/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
	///</summary>
	public abstract class SunAccountCodeProviderBaseCore : EntityViewProviderBase<SunAccountCode>
	{
		#region Custom Methods
		
		
		#region _SunAccountCode_GetList
		
		/// <summary>
		///	This method wrap the '_SunAccountCode_GetList' stored procedure. 
		/// </summary>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetList()
		{
			return GetList(null, 0, int.MaxValue );
		}
		
		/// <summary>
		///	This method wrap the '_SunAccountCode_GetList' stored procedure. 
		/// </summary>
		/// <param name="start">Row number at which to start reading.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetList(int start, int pageLength)
		{
			return GetList(null, start, pageLength );
		}
				
		/// <summary>
		///	This method wrap the '_SunAccountCode_GetList' stored procedure. 
		/// </summary>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetList(TransactionManager transactionManager)
		{
			return GetList(transactionManager, 0, int.MaxValue );
		}
		
		/// <summary>
		///	This method wrap the '_SunAccountCode_GetList' stored procedure. 
		/// </summary>
		/// <param name="start">Row number at which to start reading.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public abstract DataSet GetList(TransactionManager transactionManager, int start, int pageLength);
		
		#endregion

		
		#endregion

		#region Helper Functions
		
		/*
		///<summary>
		/// Fill an VList&lt;SunAccountCode&gt; From a DataSet
		///</summary>
		/// <param name="dataSet">the DataSet</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Start row</param>
		/// <param name="pagelen">number of row.</param>
		///<returns><see chref="VList&lt;SunAccountCode&gt;"/></returns>
		protected static VList&lt;SunAccountCode&gt; Fill(DataSet dataSet, VList<SunAccountCode> rows, int start, int pagelen)
		{
			if (dataSet.Tables.Count == 1)
			{
				return Fill(dataSet.Tables[0], rows, start, pagelen);
			}
			else
			{
				return new VList<SunAccountCode>();
			}	
		}
		
		
		///<summary>
		/// Fill an VList&lt;SunAccountCode&gt; From a DataTable
		///</summary>
		/// <param name="dataTable">the DataTable that hold the data.</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Start row</param>
		/// <param name="pagelen">number of row.</param>
		///<returns><see chref="VList<SunAccountCode>"/></returns>
		protected static VList&lt;SunAccountCode&gt; Fill(DataTable dataTable, VList<SunAccountCode> rows, int start, int pagelen)
		{
			int recordnum = 0;
			
			System.Collections.IEnumerator dataRows =  dataTable.Rows.GetEnumerator();
			
			while (dataRows.MoveNext() && (pagelen != 0))
			{
				if(recordnum >= start)
				{
					DataRow row = (DataRow)dataRows.Current;
				
					SunAccountCode c = new SunAccountCode();
					c.SunDb = (Convert.IsDBNull(row["SUN_DB"]))?string.Empty:(System.String)row["SUN_DB"];
					c.AccntCode = (Convert.IsDBNull(row["ACCNT_CODE"]))?string.Empty:(System.String)row["ACCNT_CODE"];
					c.Lookup = (Convert.IsDBNull(row["LOOKUP"]))?string.Empty:(System.String)row["LOOKUP"];
					c.Updated = (Convert.IsDBNull(row["UPDATED"]))?string.Empty:(System.String)row["UPDATED"];
					c.AccntName = (Convert.IsDBNull(row["ACCNT_NAME"]))?string.Empty:(System.String)row["ACCNT_NAME"];
					c.AccntType = (Convert.IsDBNull(row["ACCNT_TYPE"]))?string.Empty:(System.String)row["ACCNT_TYPE"];
					c.BalnceOpn = (Convert.IsDBNull(row["BALNCE_OPN"]))?string.Empty:(System.String)row["BALNCE_OPN"];
					c.Suspend = (Convert.IsDBNull(row["SUSPEND"]))?string.Empty:(System.String)row["SUSPEND"];
					c.ConvCntrl = (Convert.IsDBNull(row["CONV_CNTRL"]))?string.Empty:(System.String)row["CONV_CNTRL"];
					c.ConvCode = (Convert.IsDBNull(row["CONV_CODE"]))?string.Empty:(System.String)row["CONV_CODE"];
					c.SuppReval = (Convert.IsDBNull(row["SUPP_REVAL"]))?string.Empty:(System.String)row["SUPP_REVAL"];
					c.CommitAcc = (Convert.IsDBNull(row["COMMIT_ACC"]))?string.Empty:(System.String)row["COMMIT_ACC"];
					c.Comments = (Convert.IsDBNull(row["COMMENTS"]))?string.Empty:(System.String)row["COMMENTS"];
					c.EnterAnal = (Convert.IsDBNull(row["ENTER_ANAL"]))?string.Empty:(System.String)row["ENTER_ANAL"];
					c.AddCode = (Convert.IsDBNull(row["ADD_CODE"]))?string.Empty:(System.String)row["ADD_CODE"];
					c.DirectDb = (Convert.IsDBNull(row["DIRECT_DB"]))?string.Empty:(System.String)row["DIRECT_DB"];
					c.Priority = (Convert.IsDBNull(row["PRIORITY"]))?string.Empty:(System.String)row["PRIORITY"];
					c.PayMethod = (Convert.IsDBNull(row["PAY_METHOD"]))?string.Empty:(System.String)row["PAY_METHOD"];
					c.CreditLim = (Convert.IsDBNull(row["CREDIT_LIM"]))?0.0m:(System.Decimal)row["CREDIT_LIM"];
					c.PaymntDay = (Convert.IsDBNull(row["PAYMNT_DAY"]))?(short)0:(System.Int16)row["PAYMNT_DAY"];
					c.PaymntTrm = (Convert.IsDBNull(row["PAYMNT_TRM"]))?string.Empty:(System.String)row["PAYMNT_TRM"];
					c.DiscDays = (Convert.IsDBNull(row["DISC_DAYS"]))?(short)0:(System.Int16)row["DISC_DAYS"];
					c.Discount = (Convert.IsDBNull(row["DISCOUNT"]))?0.0m:(System.Decimal)row["DISCOUNT"];
					c.DiscDays2 = (Convert.IsDBNull(row["DISC_DAYS2"]))?(short)0:(System.Int16)row["DISC_DAYS2"];
					c.Discount2 = (Convert.IsDBNull(row["DISCOUNT_2"]))?0.0m:(System.Decimal)row["DISCOUNT_2"];
					c.LastTrans = (Convert.IsDBNull(row["LAST_TRANS"]))?string.Empty:(System.String)row["LAST_TRANS"];
					c.TransPres = (Convert.IsDBNull(row["TRANS_PRES"]))?string.Empty:(System.String)row["TRANS_PRES"];
					c.AccBalnce = (Convert.IsDBNull(row["ACC_BALNCE"]))?0.0m:(System.Decimal)row["ACC_BALNCE"];
					c.OrdBalnce = (Convert.IsDBNull(row["ORD_BALNCE"]))?0.0m:(System.Decimal)row["ORD_BALNCE"];
					c.AllocProg = (Convert.IsDBNull(row["ALLOC_PROG"]))?string.Empty:(System.String)row["ALLOC_PROG"];
					c.UserArea = (Convert.IsDBNull(row["USER_AREA"]))?string.Empty:(System.String)row["USER_AREA"];
					c.AnalA0 = (Convert.IsDBNull(row["ANAL_A0"]))?string.Empty:(System.String)row["ANAL_A0"];
					c.AnalA1 = (Convert.IsDBNull(row["ANAL_A1"]))?string.Empty:(System.String)row["ANAL_A1"];
					c.AnalA2 = (Convert.IsDBNull(row["ANAL_A2"]))?string.Empty:(System.String)row["ANAL_A2"];
					c.AnalA3 = (Convert.IsDBNull(row["ANAL_A3"]))?string.Empty:(System.String)row["ANAL_A3"];
					c.AnalA4 = (Convert.IsDBNull(row["ANAL_A4"]))?string.Empty:(System.String)row["ANAL_A4"];
					c.AnalA5 = (Convert.IsDBNull(row["ANAL_A5"]))?string.Empty:(System.String)row["ANAL_A5"];
					c.AnalA6 = (Convert.IsDBNull(row["ANAL_A6"]))?string.Empty:(System.String)row["ANAL_A6"];
					c.AnalA7 = (Convert.IsDBNull(row["ANAL_A7"]))?string.Empty:(System.String)row["ANAL_A7"];
					c.AnalA8 = (Convert.IsDBNull(row["ANAL_A8"]))?string.Empty:(System.String)row["ANAL_A8"];
					c.AnalA9 = (Convert.IsDBNull(row["ANAL_A9"]))?string.Empty:(System.String)row["ANAL_A9"];
					c.TaxCode = (Convert.IsDBNull(row["TAX_CODE"]))?string.Empty:(System.String)row["TAX_CODE"];
					c.Data1 = (Convert.IsDBNull(row["DATA_1"]))?string.Empty:(System.String)row["DATA_1"];
					c.Settlement = (Convert.IsDBNull(row["SETTLEMENT"]))?string.Empty:(System.String)row["SETTLEMENT"];
					c.LinkAcc = (Convert.IsDBNull(row["LINK_ACC"]))?string.Empty:(System.String)row["LINK_ACC"];
					c.DefBankCode = (Convert.IsDBNull(row["DEF_BANK_CODE"]))?string.Empty:(System.String)row["DEF_BANK_CODE"];
					c.OverTolInd = (Convert.IsDBNull(row["OVER_TOL_IND"]))?string.Empty:(System.String)row["OVER_TOL_IND"];
					c.TolDays = (Convert.IsDBNull(row["TOL_DAYS"]))?(short)0:(System.Int16)row["TOL_DAYS"];
					c.AcceptChanges();
					rows.Add(c);
					pagelen -= 1;
				}
				recordnum += 1;
			}
			return rows;
		}
		*/	
						
		///<summary>
		/// Fill an <see cref="VList&lt;SunAccountCode&gt;"/> From a DataReader.
		///</summary>
		/// <param name="reader">Datareader</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Start row</param>
		/// <param name="pageLength">number of row.</param>
		///<returns>a <see cref="VList&lt;SunAccountCode&gt;"/></returns>
		protected VList<SunAccountCode> Fill(IDataReader reader, VList<SunAccountCode> rows, int start, int pageLength)
		{
			int recordnum = 0;
			while (reader.Read() && (pageLength != 0))
			{
				if(recordnum >= start)
				{
					SunAccountCode entity = null;
					if (DataRepository.Provider.UseEntityFactory)
					{
						entity = EntityManager.CreateViewEntity<SunAccountCode>("SunAccountCode",  DataRepository.Provider.EntityCreationalFactoryType); 
					}
					else
					{
						entity = new SunAccountCode();
					}
					
					entity.SuppressEntityEvents = true;

					entity.SunDb = (System.String)reader[((int)SunAccountCodeColumn.SunDb)];
					//entity.SunDb = (Convert.IsDBNull(reader["SUN_DB"]))?string.Empty:(System.String)reader["SUN_DB"];
					entity.AccntCode = (System.String)reader[((int)SunAccountCodeColumn.AccntCode)];
					//entity.AccntCode = (Convert.IsDBNull(reader["ACCNT_CODE"]))?string.Empty:(System.String)reader["ACCNT_CODE"];
					entity.Lookup = (System.String)reader[((int)SunAccountCodeColumn.Lookup)];
					//entity.Lookup = (Convert.IsDBNull(reader["LOOKUP"]))?string.Empty:(System.String)reader["LOOKUP"];
					entity.Updated = (System.String)reader[((int)SunAccountCodeColumn.Updated)];
					//entity.Updated = (Convert.IsDBNull(reader["UPDATED"]))?string.Empty:(System.String)reader["UPDATED"];
					entity.AccntName = (System.String)reader[((int)SunAccountCodeColumn.AccntName)];
					//entity.AccntName = (Convert.IsDBNull(reader["ACCNT_NAME"]))?string.Empty:(System.String)reader["ACCNT_NAME"];
					entity.AccntType = (System.String)reader[((int)SunAccountCodeColumn.AccntType)];
					//entity.AccntType = (Convert.IsDBNull(reader["ACCNT_TYPE"]))?string.Empty:(System.String)reader["ACCNT_TYPE"];
					entity.BalnceOpn = (System.String)reader[((int)SunAccountCodeColumn.BalnceOpn)];
					//entity.BalnceOpn = (Convert.IsDBNull(reader["BALNCE_OPN"]))?string.Empty:(System.String)reader["BALNCE_OPN"];
					entity.Suspend = (System.String)reader[((int)SunAccountCodeColumn.Suspend)];
					//entity.Suspend = (Convert.IsDBNull(reader["SUSPEND"]))?string.Empty:(System.String)reader["SUSPEND"];
					entity.ConvCntrl = (System.String)reader[((int)SunAccountCodeColumn.ConvCntrl)];
					//entity.ConvCntrl = (Convert.IsDBNull(reader["CONV_CNTRL"]))?string.Empty:(System.String)reader["CONV_CNTRL"];
					entity.ConvCode = (System.String)reader[((int)SunAccountCodeColumn.ConvCode)];
					//entity.ConvCode = (Convert.IsDBNull(reader["CONV_CODE"]))?string.Empty:(System.String)reader["CONV_CODE"];
					entity.SuppReval = (System.String)reader[((int)SunAccountCodeColumn.SuppReval)];
					//entity.SuppReval = (Convert.IsDBNull(reader["SUPP_REVAL"]))?string.Empty:(System.String)reader["SUPP_REVAL"];
					entity.CommitAcc = (System.String)reader[((int)SunAccountCodeColumn.CommitAcc)];
					//entity.CommitAcc = (Convert.IsDBNull(reader["COMMIT_ACC"]))?string.Empty:(System.String)reader["COMMIT_ACC"];
					entity.Comments = (System.String)reader[((int)SunAccountCodeColumn.Comments)];
					//entity.Comments = (Convert.IsDBNull(reader["COMMENTS"]))?string.Empty:(System.String)reader["COMMENTS"];
					entity.EnterAnal = (System.String)reader[((int)SunAccountCodeColumn.EnterAnal)];
					//entity.EnterAnal = (Convert.IsDBNull(reader["ENTER_ANAL"]))?string.Empty:(System.String)reader["ENTER_ANAL"];
					entity.AddCode = (System.String)reader[((int)SunAccountCodeColumn.AddCode)];
					//entity.AddCode = (Convert.IsDBNull(reader["ADD_CODE"]))?string.Empty:(System.String)reader["ADD_CODE"];
					entity.DirectDb = (System.String)reader[((int)SunAccountCodeColumn.DirectDb)];
					//entity.DirectDb = (Convert.IsDBNull(reader["DIRECT_DB"]))?string.Empty:(System.String)reader["DIRECT_DB"];
					entity.Priority = (System.String)reader[((int)SunAccountCodeColumn.Priority)];
					//entity.Priority = (Convert.IsDBNull(reader["PRIORITY"]))?string.Empty:(System.String)reader["PRIORITY"];
					entity.PayMethod = (System.String)reader[((int)SunAccountCodeColumn.PayMethod)];
					//entity.PayMethod = (Convert.IsDBNull(reader["PAY_METHOD"]))?string.Empty:(System.String)reader["PAY_METHOD"];
					entity.CreditLim = (System.Decimal)reader[((int)SunAccountCodeColumn.CreditLim)];
					//entity.CreditLim = (Convert.IsDBNull(reader["CREDIT_LIM"]))?0.0m:(System.Decimal)reader["CREDIT_LIM"];
					entity.PaymntDay = (System.Int16)reader[((int)SunAccountCodeColumn.PaymntDay)];
					//entity.PaymntDay = (Convert.IsDBNull(reader["PAYMNT_DAY"]))?(short)0:(System.Int16)reader["PAYMNT_DAY"];
					entity.PaymntTrm = (System.String)reader[((int)SunAccountCodeColumn.PaymntTrm)];
					//entity.PaymntTrm = (Convert.IsDBNull(reader["PAYMNT_TRM"]))?string.Empty:(System.String)reader["PAYMNT_TRM"];
					entity.DiscDays = (System.Int16)reader[((int)SunAccountCodeColumn.DiscDays)];
					//entity.DiscDays = (Convert.IsDBNull(reader["DISC_DAYS"]))?(short)0:(System.Int16)reader["DISC_DAYS"];
					entity.Discount = (System.Decimal)reader[((int)SunAccountCodeColumn.Discount)];
					//entity.Discount = (Convert.IsDBNull(reader["DISCOUNT"]))?0.0m:(System.Decimal)reader["DISCOUNT"];
					entity.DiscDays2 = (System.Int16)reader[((int)SunAccountCodeColumn.DiscDays2)];
					//entity.DiscDays2 = (Convert.IsDBNull(reader["DISC_DAYS2"]))?(short)0:(System.Int16)reader["DISC_DAYS2"];
					entity.Discount2 = (System.Decimal)reader[((int)SunAccountCodeColumn.Discount2)];
					//entity.Discount2 = (Convert.IsDBNull(reader["DISCOUNT_2"]))?0.0m:(System.Decimal)reader["DISCOUNT_2"];
					entity.LastTrans = (System.String)reader[((int)SunAccountCodeColumn.LastTrans)];
					//entity.LastTrans = (Convert.IsDBNull(reader["LAST_TRANS"]))?string.Empty:(System.String)reader["LAST_TRANS"];
					entity.TransPres = (System.String)reader[((int)SunAccountCodeColumn.TransPres)];
					//entity.TransPres = (Convert.IsDBNull(reader["TRANS_PRES"]))?string.Empty:(System.String)reader["TRANS_PRES"];
					entity.AccBalnce = (System.Decimal)reader[((int)SunAccountCodeColumn.AccBalnce)];
					//entity.AccBalnce = (Convert.IsDBNull(reader["ACC_BALNCE"]))?0.0m:(System.Decimal)reader["ACC_BALNCE"];
					entity.OrdBalnce = (System.Decimal)reader[((int)SunAccountCodeColumn.OrdBalnce)];
					//entity.OrdBalnce = (Convert.IsDBNull(reader["ORD_BALNCE"]))?0.0m:(System.Decimal)reader["ORD_BALNCE"];
					entity.AllocProg = (System.String)reader[((int)SunAccountCodeColumn.AllocProg)];
					//entity.AllocProg = (Convert.IsDBNull(reader["ALLOC_PROG"]))?string.Empty:(System.String)reader["ALLOC_PROG"];
					entity.UserArea = (System.String)reader[((int)SunAccountCodeColumn.UserArea)];
					//entity.UserArea = (Convert.IsDBNull(reader["USER_AREA"]))?string.Empty:(System.String)reader["USER_AREA"];
					entity.AnalA0 = (System.String)reader[((int)SunAccountCodeColumn.AnalA0)];
					//entity.AnalA0 = (Convert.IsDBNull(reader["ANAL_A0"]))?string.Empty:(System.String)reader["ANAL_A0"];
					entity.AnalA1 = (System.String)reader[((int)SunAccountCodeColumn.AnalA1)];
					//entity.AnalA1 = (Convert.IsDBNull(reader["ANAL_A1"]))?string.Empty:(System.String)reader["ANAL_A1"];
					entity.AnalA2 = (System.String)reader[((int)SunAccountCodeColumn.AnalA2)];
					//entity.AnalA2 = (Convert.IsDBNull(reader["ANAL_A2"]))?string.Empty:(System.String)reader["ANAL_A2"];
					entity.AnalA3 = (System.String)reader[((int)SunAccountCodeColumn.AnalA3)];
					//entity.AnalA3 = (Convert.IsDBNull(reader["ANAL_A3"]))?string.Empty:(System.String)reader["ANAL_A3"];
					entity.AnalA4 = (System.String)reader[((int)SunAccountCodeColumn.AnalA4)];
					//entity.AnalA4 = (Convert.IsDBNull(reader["ANAL_A4"]))?string.Empty:(System.String)reader["ANAL_A4"];
					entity.AnalA5 = (System.String)reader[((int)SunAccountCodeColumn.AnalA5)];
					//entity.AnalA5 = (Convert.IsDBNull(reader["ANAL_A5"]))?string.Empty:(System.String)reader["ANAL_A5"];
					entity.AnalA6 = (System.String)reader[((int)SunAccountCodeColumn.AnalA6)];
					//entity.AnalA6 = (Convert.IsDBNull(reader["ANAL_A6"]))?string.Empty:(System.String)reader["ANAL_A6"];
					entity.AnalA7 = (System.String)reader[((int)SunAccountCodeColumn.AnalA7)];
					//entity.AnalA7 = (Convert.IsDBNull(reader["ANAL_A7"]))?string.Empty:(System.String)reader["ANAL_A7"];
					entity.AnalA8 = (System.String)reader[((int)SunAccountCodeColumn.AnalA8)];
					//entity.AnalA8 = (Convert.IsDBNull(reader["ANAL_A8"]))?string.Empty:(System.String)reader["ANAL_A8"];
					entity.AnalA9 = (System.String)reader[((int)SunAccountCodeColumn.AnalA9)];
					//entity.AnalA9 = (Convert.IsDBNull(reader["ANAL_A9"]))?string.Empty:(System.String)reader["ANAL_A9"];
					entity.TaxCode = (System.String)reader[((int)SunAccountCodeColumn.TaxCode)];
					//entity.TaxCode = (Convert.IsDBNull(reader["TAX_CODE"]))?string.Empty:(System.String)reader["TAX_CODE"];
					entity.Data1 = (System.String)reader[((int)SunAccountCodeColumn.Data1)];
					//entity.Data1 = (Convert.IsDBNull(reader["DATA_1"]))?string.Empty:(System.String)reader["DATA_1"];
					entity.Settlement = (System.String)reader[((int)SunAccountCodeColumn.Settlement)];
					//entity.Settlement = (Convert.IsDBNull(reader["SETTLEMENT"]))?string.Empty:(System.String)reader["SETTLEMENT"];
					entity.LinkAcc = (System.String)reader[((int)SunAccountCodeColumn.LinkAcc)];
					//entity.LinkAcc = (Convert.IsDBNull(reader["LINK_ACC"]))?string.Empty:(System.String)reader["LINK_ACC"];
					entity.DefBankCode = (System.String)reader[((int)SunAccountCodeColumn.DefBankCode)];
					//entity.DefBankCode = (Convert.IsDBNull(reader["DEF_BANK_CODE"]))?string.Empty:(System.String)reader["DEF_BANK_CODE"];
					entity.OverTolInd = (System.String)reader[((int)SunAccountCodeColumn.OverTolInd)];
					//entity.OverTolInd = (Convert.IsDBNull(reader["OVER_TOL_IND"]))?string.Empty:(System.String)reader["OVER_TOL_IND"];
					entity.TolDays = (System.Int16)reader[((int)SunAccountCodeColumn.TolDays)];
					//entity.TolDays = (Convert.IsDBNull(reader["TOL_DAYS"]))?(short)0:(System.Int16)reader["TOL_DAYS"];
					entity.AcceptChanges();
					entity.SuppressEntityEvents = false;
					
					rows.Add(entity);
					pageLength -= 1;
				}
				recordnum += 1;
			}
			return rows;
		}
		
		
		/// <summary>
		/// Refreshes the <see cref="SunAccountCode"/> object from the <see cref="IDataReader"/>.
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader"/> to read from.</param>
		/// <param name="entity">The <see cref="SunAccountCode"/> object to refresh.</param>
		protected void RefreshEntity(IDataReader reader, SunAccountCode entity)
		{
			reader.Read();
			entity.SunDb = (System.String)reader[((int)SunAccountCodeColumn.SunDb)];
			//entity.SunDb = (Convert.IsDBNull(reader["SUN_DB"]))?string.Empty:(System.String)reader["SUN_DB"];
			entity.AccntCode = (System.String)reader[((int)SunAccountCodeColumn.AccntCode)];
			//entity.AccntCode = (Convert.IsDBNull(reader["ACCNT_CODE"]))?string.Empty:(System.String)reader["ACCNT_CODE"];
			entity.Lookup = (System.String)reader[((int)SunAccountCodeColumn.Lookup)];
			//entity.Lookup = (Convert.IsDBNull(reader["LOOKUP"]))?string.Empty:(System.String)reader["LOOKUP"];
			entity.Updated = (System.String)reader[((int)SunAccountCodeColumn.Updated)];
			//entity.Updated = (Convert.IsDBNull(reader["UPDATED"]))?string.Empty:(System.String)reader["UPDATED"];
			entity.AccntName = (System.String)reader[((int)SunAccountCodeColumn.AccntName)];
			//entity.AccntName = (Convert.IsDBNull(reader["ACCNT_NAME"]))?string.Empty:(System.String)reader["ACCNT_NAME"];
			entity.AccntType = (System.String)reader[((int)SunAccountCodeColumn.AccntType)];
			//entity.AccntType = (Convert.IsDBNull(reader["ACCNT_TYPE"]))?string.Empty:(System.String)reader["ACCNT_TYPE"];
			entity.BalnceOpn = (System.String)reader[((int)SunAccountCodeColumn.BalnceOpn)];
			//entity.BalnceOpn = (Convert.IsDBNull(reader["BALNCE_OPN"]))?string.Empty:(System.String)reader["BALNCE_OPN"];
			entity.Suspend = (System.String)reader[((int)SunAccountCodeColumn.Suspend)];
			//entity.Suspend = (Convert.IsDBNull(reader["SUSPEND"]))?string.Empty:(System.String)reader["SUSPEND"];
			entity.ConvCntrl = (System.String)reader[((int)SunAccountCodeColumn.ConvCntrl)];
			//entity.ConvCntrl = (Convert.IsDBNull(reader["CONV_CNTRL"]))?string.Empty:(System.String)reader["CONV_CNTRL"];
			entity.ConvCode = (System.String)reader[((int)SunAccountCodeColumn.ConvCode)];
			//entity.ConvCode = (Convert.IsDBNull(reader["CONV_CODE"]))?string.Empty:(System.String)reader["CONV_CODE"];
			entity.SuppReval = (System.String)reader[((int)SunAccountCodeColumn.SuppReval)];
			//entity.SuppReval = (Convert.IsDBNull(reader["SUPP_REVAL"]))?string.Empty:(System.String)reader["SUPP_REVAL"];
			entity.CommitAcc = (System.String)reader[((int)SunAccountCodeColumn.CommitAcc)];
			//entity.CommitAcc = (Convert.IsDBNull(reader["COMMIT_ACC"]))?string.Empty:(System.String)reader["COMMIT_ACC"];
			entity.Comments = (System.String)reader[((int)SunAccountCodeColumn.Comments)];
			//entity.Comments = (Convert.IsDBNull(reader["COMMENTS"]))?string.Empty:(System.String)reader["COMMENTS"];
			entity.EnterAnal = (System.String)reader[((int)SunAccountCodeColumn.EnterAnal)];
			//entity.EnterAnal = (Convert.IsDBNull(reader["ENTER_ANAL"]))?string.Empty:(System.String)reader["ENTER_ANAL"];
			entity.AddCode = (System.String)reader[((int)SunAccountCodeColumn.AddCode)];
			//entity.AddCode = (Convert.IsDBNull(reader["ADD_CODE"]))?string.Empty:(System.String)reader["ADD_CODE"];
			entity.DirectDb = (System.String)reader[((int)SunAccountCodeColumn.DirectDb)];
			//entity.DirectDb = (Convert.IsDBNull(reader["DIRECT_DB"]))?string.Empty:(System.String)reader["DIRECT_DB"];
			entity.Priority = (System.String)reader[((int)SunAccountCodeColumn.Priority)];
			//entity.Priority = (Convert.IsDBNull(reader["PRIORITY"]))?string.Empty:(System.String)reader["PRIORITY"];
			entity.PayMethod = (System.String)reader[((int)SunAccountCodeColumn.PayMethod)];
			//entity.PayMethod = (Convert.IsDBNull(reader["PAY_METHOD"]))?string.Empty:(System.String)reader["PAY_METHOD"];
			entity.CreditLim = (System.Decimal)reader[((int)SunAccountCodeColumn.CreditLim)];
			//entity.CreditLim = (Convert.IsDBNull(reader["CREDIT_LIM"]))?0.0m:(System.Decimal)reader["CREDIT_LIM"];
			entity.PaymntDay = (System.Int16)reader[((int)SunAccountCodeColumn.PaymntDay)];
			//entity.PaymntDay = (Convert.IsDBNull(reader["PAYMNT_DAY"]))?(short)0:(System.Int16)reader["PAYMNT_DAY"];
			entity.PaymntTrm = (System.String)reader[((int)SunAccountCodeColumn.PaymntTrm)];
			//entity.PaymntTrm = (Convert.IsDBNull(reader["PAYMNT_TRM"]))?string.Empty:(System.String)reader["PAYMNT_TRM"];
			entity.DiscDays = (System.Int16)reader[((int)SunAccountCodeColumn.DiscDays)];
			//entity.DiscDays = (Convert.IsDBNull(reader["DISC_DAYS"]))?(short)0:(System.Int16)reader["DISC_DAYS"];
			entity.Discount = (System.Decimal)reader[((int)SunAccountCodeColumn.Discount)];
			//entity.Discount = (Convert.IsDBNull(reader["DISCOUNT"]))?0.0m:(System.Decimal)reader["DISCOUNT"];
			entity.DiscDays2 = (System.Int16)reader[((int)SunAccountCodeColumn.DiscDays2)];
			//entity.DiscDays2 = (Convert.IsDBNull(reader["DISC_DAYS2"]))?(short)0:(System.Int16)reader["DISC_DAYS2"];
			entity.Discount2 = (System.Decimal)reader[((int)SunAccountCodeColumn.Discount2)];
			//entity.Discount2 = (Convert.IsDBNull(reader["DISCOUNT_2"]))?0.0m:(System.Decimal)reader["DISCOUNT_2"];
			entity.LastTrans = (System.String)reader[((int)SunAccountCodeColumn.LastTrans)];
			//entity.LastTrans = (Convert.IsDBNull(reader["LAST_TRANS"]))?string.Empty:(System.String)reader["LAST_TRANS"];
			entity.TransPres = (System.String)reader[((int)SunAccountCodeColumn.TransPres)];
			//entity.TransPres = (Convert.IsDBNull(reader["TRANS_PRES"]))?string.Empty:(System.String)reader["TRANS_PRES"];
			entity.AccBalnce = (System.Decimal)reader[((int)SunAccountCodeColumn.AccBalnce)];
			//entity.AccBalnce = (Convert.IsDBNull(reader["ACC_BALNCE"]))?0.0m:(System.Decimal)reader["ACC_BALNCE"];
			entity.OrdBalnce = (System.Decimal)reader[((int)SunAccountCodeColumn.OrdBalnce)];
			//entity.OrdBalnce = (Convert.IsDBNull(reader["ORD_BALNCE"]))?0.0m:(System.Decimal)reader["ORD_BALNCE"];
			entity.AllocProg = (System.String)reader[((int)SunAccountCodeColumn.AllocProg)];
			//entity.AllocProg = (Convert.IsDBNull(reader["ALLOC_PROG"]))?string.Empty:(System.String)reader["ALLOC_PROG"];
			entity.UserArea = (System.String)reader[((int)SunAccountCodeColumn.UserArea)];
			//entity.UserArea = (Convert.IsDBNull(reader["USER_AREA"]))?string.Empty:(System.String)reader["USER_AREA"];
			entity.AnalA0 = (System.String)reader[((int)SunAccountCodeColumn.AnalA0)];
			//entity.AnalA0 = (Convert.IsDBNull(reader["ANAL_A0"]))?string.Empty:(System.String)reader["ANAL_A0"];
			entity.AnalA1 = (System.String)reader[((int)SunAccountCodeColumn.AnalA1)];
			//entity.AnalA1 = (Convert.IsDBNull(reader["ANAL_A1"]))?string.Empty:(System.String)reader["ANAL_A1"];
			entity.AnalA2 = (System.String)reader[((int)SunAccountCodeColumn.AnalA2)];
			//entity.AnalA2 = (Convert.IsDBNull(reader["ANAL_A2"]))?string.Empty:(System.String)reader["ANAL_A2"];
			entity.AnalA3 = (System.String)reader[((int)SunAccountCodeColumn.AnalA3)];
			//entity.AnalA3 = (Convert.IsDBNull(reader["ANAL_A3"]))?string.Empty:(System.String)reader["ANAL_A3"];
			entity.AnalA4 = (System.String)reader[((int)SunAccountCodeColumn.AnalA4)];
			//entity.AnalA4 = (Convert.IsDBNull(reader["ANAL_A4"]))?string.Empty:(System.String)reader["ANAL_A4"];
			entity.AnalA5 = (System.String)reader[((int)SunAccountCodeColumn.AnalA5)];
			//entity.AnalA5 = (Convert.IsDBNull(reader["ANAL_A5"]))?string.Empty:(System.String)reader["ANAL_A5"];
			entity.AnalA6 = (System.String)reader[((int)SunAccountCodeColumn.AnalA6)];
			//entity.AnalA6 = (Convert.IsDBNull(reader["ANAL_A6"]))?string.Empty:(System.String)reader["ANAL_A6"];
			entity.AnalA7 = (System.String)reader[((int)SunAccountCodeColumn.AnalA7)];
			//entity.AnalA7 = (Convert.IsDBNull(reader["ANAL_A7"]))?string.Empty:(System.String)reader["ANAL_A7"];
			entity.AnalA8 = (System.String)reader[((int)SunAccountCodeColumn.AnalA8)];
			//entity.AnalA8 = (Convert.IsDBNull(reader["ANAL_A8"]))?string.Empty:(System.String)reader["ANAL_A8"];
			entity.AnalA9 = (System.String)reader[((int)SunAccountCodeColumn.AnalA9)];
			//entity.AnalA9 = (Convert.IsDBNull(reader["ANAL_A9"]))?string.Empty:(System.String)reader["ANAL_A9"];
			entity.TaxCode = (System.String)reader[((int)SunAccountCodeColumn.TaxCode)];
			//entity.TaxCode = (Convert.IsDBNull(reader["TAX_CODE"]))?string.Empty:(System.String)reader["TAX_CODE"];
			entity.Data1 = (System.String)reader[((int)SunAccountCodeColumn.Data1)];
			//entity.Data1 = (Convert.IsDBNull(reader["DATA_1"]))?string.Empty:(System.String)reader["DATA_1"];
			entity.Settlement = (System.String)reader[((int)SunAccountCodeColumn.Settlement)];
			//entity.Settlement = (Convert.IsDBNull(reader["SETTLEMENT"]))?string.Empty:(System.String)reader["SETTLEMENT"];
			entity.LinkAcc = (System.String)reader[((int)SunAccountCodeColumn.LinkAcc)];
			//entity.LinkAcc = (Convert.IsDBNull(reader["LINK_ACC"]))?string.Empty:(System.String)reader["LINK_ACC"];
			entity.DefBankCode = (System.String)reader[((int)SunAccountCodeColumn.DefBankCode)];
			//entity.DefBankCode = (Convert.IsDBNull(reader["DEF_BANK_CODE"]))?string.Empty:(System.String)reader["DEF_BANK_CODE"];
			entity.OverTolInd = (System.String)reader[((int)SunAccountCodeColumn.OverTolInd)];
			//entity.OverTolInd = (Convert.IsDBNull(reader["OVER_TOL_IND"]))?string.Empty:(System.String)reader["OVER_TOL_IND"];
			entity.TolDays = (System.Int16)reader[((int)SunAccountCodeColumn.TolDays)];
			//entity.TolDays = (Convert.IsDBNull(reader["TOL_DAYS"]))?(short)0:(System.Int16)reader["TOL_DAYS"];
			reader.Close();
	
			entity.AcceptChanges();
		}
		
		/*
		/// <summary>
		/// Refreshes the <see cref="SunAccountCode"/> object from the <see cref="DataSet"/>.
		/// </summary>
		/// <param name="dataSet">The <see cref="DataSet"/> to read from.</param>
		/// <param name="entity">The <see cref="SunAccountCode"/> object.</param>
		protected static void RefreshEntity(DataSet dataSet, SunAccountCode entity)
		{
			DataRow dataRow = dataSet.Tables[0].Rows[0];
			
			entity.SunDb = (Convert.IsDBNull(dataRow["SUN_DB"]))?string.Empty:(System.String)dataRow["SUN_DB"];
			entity.AccntCode = (Convert.IsDBNull(dataRow["ACCNT_CODE"]))?string.Empty:(System.String)dataRow["ACCNT_CODE"];
			entity.Lookup = (Convert.IsDBNull(dataRow["LOOKUP"]))?string.Empty:(System.String)dataRow["LOOKUP"];
			entity.Updated = (Convert.IsDBNull(dataRow["UPDATED"]))?string.Empty:(System.String)dataRow["UPDATED"];
			entity.AccntName = (Convert.IsDBNull(dataRow["ACCNT_NAME"]))?string.Empty:(System.String)dataRow["ACCNT_NAME"];
			entity.AccntType = (Convert.IsDBNull(dataRow["ACCNT_TYPE"]))?string.Empty:(System.String)dataRow["ACCNT_TYPE"];
			entity.BalnceOpn = (Convert.IsDBNull(dataRow["BALNCE_OPN"]))?string.Empty:(System.String)dataRow["BALNCE_OPN"];
			entity.Suspend = (Convert.IsDBNull(dataRow["SUSPEND"]))?string.Empty:(System.String)dataRow["SUSPEND"];
			entity.ConvCntrl = (Convert.IsDBNull(dataRow["CONV_CNTRL"]))?string.Empty:(System.String)dataRow["CONV_CNTRL"];
			entity.ConvCode = (Convert.IsDBNull(dataRow["CONV_CODE"]))?string.Empty:(System.String)dataRow["CONV_CODE"];
			entity.SuppReval = (Convert.IsDBNull(dataRow["SUPP_REVAL"]))?string.Empty:(System.String)dataRow["SUPP_REVAL"];
			entity.CommitAcc = (Convert.IsDBNull(dataRow["COMMIT_ACC"]))?string.Empty:(System.String)dataRow["COMMIT_ACC"];
			entity.Comments = (Convert.IsDBNull(dataRow["COMMENTS"]))?string.Empty:(System.String)dataRow["COMMENTS"];
			entity.EnterAnal = (Convert.IsDBNull(dataRow["ENTER_ANAL"]))?string.Empty:(System.String)dataRow["ENTER_ANAL"];
			entity.AddCode = (Convert.IsDBNull(dataRow["ADD_CODE"]))?string.Empty:(System.String)dataRow["ADD_CODE"];
			entity.DirectDb = (Convert.IsDBNull(dataRow["DIRECT_DB"]))?string.Empty:(System.String)dataRow["DIRECT_DB"];
			entity.Priority = (Convert.IsDBNull(dataRow["PRIORITY"]))?string.Empty:(System.String)dataRow["PRIORITY"];
			entity.PayMethod = (Convert.IsDBNull(dataRow["PAY_METHOD"]))?string.Empty:(System.String)dataRow["PAY_METHOD"];
			entity.CreditLim = (Convert.IsDBNull(dataRow["CREDIT_LIM"]))?0.0m:(System.Decimal)dataRow["CREDIT_LIM"];
			entity.PaymntDay = (Convert.IsDBNull(dataRow["PAYMNT_DAY"]))?(short)0:(System.Int16)dataRow["PAYMNT_DAY"];
			entity.PaymntTrm = (Convert.IsDBNull(dataRow["PAYMNT_TRM"]))?string.Empty:(System.String)dataRow["PAYMNT_TRM"];
			entity.DiscDays = (Convert.IsDBNull(dataRow["DISC_DAYS"]))?(short)0:(System.Int16)dataRow["DISC_DAYS"];
			entity.Discount = (Convert.IsDBNull(dataRow["DISCOUNT"]))?0.0m:(System.Decimal)dataRow["DISCOUNT"];
			entity.DiscDays2 = (Convert.IsDBNull(dataRow["DISC_DAYS2"]))?(short)0:(System.Int16)dataRow["DISC_DAYS2"];
			entity.Discount2 = (Convert.IsDBNull(dataRow["DISCOUNT_2"]))?0.0m:(System.Decimal)dataRow["DISCOUNT_2"];
			entity.LastTrans = (Convert.IsDBNull(dataRow["LAST_TRANS"]))?string.Empty:(System.String)dataRow["LAST_TRANS"];
			entity.TransPres = (Convert.IsDBNull(dataRow["TRANS_PRES"]))?string.Empty:(System.String)dataRow["TRANS_PRES"];
			entity.AccBalnce = (Convert.IsDBNull(dataRow["ACC_BALNCE"]))?0.0m:(System.Decimal)dataRow["ACC_BALNCE"];
			entity.OrdBalnce = (Convert.IsDBNull(dataRow["ORD_BALNCE"]))?0.0m:(System.Decimal)dataRow["ORD_BALNCE"];
			entity.AllocProg = (Convert.IsDBNull(dataRow["ALLOC_PROG"]))?string.Empty:(System.String)dataRow["ALLOC_PROG"];
			entity.UserArea = (Convert.IsDBNull(dataRow["USER_AREA"]))?string.Empty:(System.String)dataRow["USER_AREA"];
			entity.AnalA0 = (Convert.IsDBNull(dataRow["ANAL_A0"]))?string.Empty:(System.String)dataRow["ANAL_A0"];
			entity.AnalA1 = (Convert.IsDBNull(dataRow["ANAL_A1"]))?string.Empty:(System.String)dataRow["ANAL_A1"];
			entity.AnalA2 = (Convert.IsDBNull(dataRow["ANAL_A2"]))?string.Empty:(System.String)dataRow["ANAL_A2"];
			entity.AnalA3 = (Convert.IsDBNull(dataRow["ANAL_A3"]))?string.Empty:(System.String)dataRow["ANAL_A3"];
			entity.AnalA4 = (Convert.IsDBNull(dataRow["ANAL_A4"]))?string.Empty:(System.String)dataRow["ANAL_A4"];
			entity.AnalA5 = (Convert.IsDBNull(dataRow["ANAL_A5"]))?string.Empty:(System.String)dataRow["ANAL_A5"];
			entity.AnalA6 = (Convert.IsDBNull(dataRow["ANAL_A6"]))?string.Empty:(System.String)dataRow["ANAL_A6"];
			entity.AnalA7 = (Convert.IsDBNull(dataRow["ANAL_A7"]))?string.Empty:(System.String)dataRow["ANAL_A7"];
			entity.AnalA8 = (Convert.IsDBNull(dataRow["ANAL_A8"]))?string.Empty:(System.String)dataRow["ANAL_A8"];
			entity.AnalA9 = (Convert.IsDBNull(dataRow["ANAL_A9"]))?string.Empty:(System.String)dataRow["ANAL_A9"];
			entity.TaxCode = (Convert.IsDBNull(dataRow["TAX_CODE"]))?string.Empty:(System.String)dataRow["TAX_CODE"];
			entity.Data1 = (Convert.IsDBNull(dataRow["DATA_1"]))?string.Empty:(System.String)dataRow["DATA_1"];
			entity.Settlement = (Convert.IsDBNull(dataRow["SETTLEMENT"]))?string.Empty:(System.String)dataRow["SETTLEMENT"];
			entity.LinkAcc = (Convert.IsDBNull(dataRow["LINK_ACC"]))?string.Empty:(System.String)dataRow["LINK_ACC"];
			entity.DefBankCode = (Convert.IsDBNull(dataRow["DEF_BANK_CODE"]))?string.Empty:(System.String)dataRow["DEF_BANK_CODE"];
			entity.OverTolInd = (Convert.IsDBNull(dataRow["OVER_TOL_IND"]))?string.Empty:(System.String)dataRow["OVER_TOL_IND"];
			entity.TolDays = (Convert.IsDBNull(dataRow["TOL_DAYS"]))?(short)0:(System.Int16)dataRow["TOL_DAYS"];
			entity.AcceptChanges();
		}
		*/
			
		#endregion Helper Functions
	}//end class

	#region SunAccountCodeFilterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilterBuilder&lt;EntityColumn&gt;"/> class
	/// that is used exclusively with a <see cref="SunAccountCode"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class SunAccountCodeFilterBuilder : SqlFilterBuilder<SunAccountCodeColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the SunAccountCodeFilterBuilder class.
		/// </summary>
		public SunAccountCodeFilterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the SunAccountCodeFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public SunAccountCodeFilterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the SunAccountCodeFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public SunAccountCodeFilterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion SunAccountCodeFilterBuilder

	#region SunAccountCodeParameterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ParameterizedSqlFilterBuilder&lt;EntityColumn&gt;"/> class
	/// that is used exclusively with a <see cref="SunAccountCode"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class SunAccountCodeParameterBuilder : ParameterizedSqlFilterBuilder<SunAccountCodeColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the SunAccountCodeParameterBuilder class.
		/// </summary>
		public SunAccountCodeParameterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the SunAccountCodeParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public SunAccountCodeParameterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the SunAccountCodeParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public SunAccountCodeParameterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion SunAccountCodeParameterBuilder
	
	#region SunAccountCodeSortBuilder
    
    /// <summary>
    /// A strongly-typed instance of the <see cref="SqlSortBuilder&lt;EntityColumn&gt;"/> class
	/// that is used exclusively with a <see cref="SunAccountCode"/> object.
    /// </summary>
    [CLSCompliant(true)]
    public class SunAccountCodeSortBuilder : SqlSortBuilder<SunAccountCodeColumn>
    {
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the SunAccountCodeSqlSortBuilder class.
		/// </summary>
		public SunAccountCodeSortBuilder() : base() { }

		#endregion Constructors

    }    
    #endregion SunAccountCodeSortBuilder

} // end namespace
